<template>
	<el-container>
		<el-main class='x-main-edit'>
			<el-form ref="form" :rules="form_rules" :model="form" size="mini" label-width="15%">
				<el-tabs type="border-card" v-model="page_tag">
					<!---->
					<!---->
					<el-tab-pane :label="page_info.title" name="1">
						<el-form-item label="OPENID" prop="rquan_openid">
							<el-input v-model="form.rquan_openid" class="x-input-60"></el-input>
						</el-form-item>
						<el-form-item label="标题" prop="rquan_title">
							<el-input v-model="form.rquan_title" class="x-input-60"></el-input>
						</el-form-item>
						<el-form-item label="类型" prop="rquan_type">
							<el-radio-group v-model="form.rquan_type">
								<el-radio v-for="(val,key) in page_info.types" :key="key" :label="key">
									{{ val }}
								</el-radio>
							</el-radio-group>
						</el-form-item>
						<el-form-item v-show="form.rquan_type==0" label="图片" prop="rquan_url">
							<x-upload-imgs ref="uploadEle" :sortable="true" :max-num="6"
										   :rules="({ maxSize: 0.5})"
										   :img_root="page_info.static_file_root"
										   v-bind:value.sync="form.rquan_url"
										   :remote-fuc="g_page.funcUpdateImg"
										   :before-upload="g_page.funcUpdateImgBefore"/>
						</el-form-item>
						<div v-show="form.rquan_type==1">
							<el-form-item label="视频封面图" prop="rquan_pic_video">
								<x-upload-imgs ref="uploadEle" :sortable="true" :max-num="1"
											   :rules="({ maxSize: 0.5})"
											   :img_root="page_info.static_file_root"
											   v-bind:value.sync="form.rquan_pic_video"
											   :remote-fuc="g_page.funcUpdateImg"
											   :before-upload="g_page.funcUpdateImgBefore"/>
							</el-form-item>
							<el-form-item label="附件" prop="rquan_url">
								<FileList v-bind:value.sync="form.rquan_url"
										  :rules="{file_size_max:5}"
										  :accept="file_accept"
										  :img_root="page_info.static_file_root" :max="1">
								</FileList>
							</el-form-item>
						</div>
						<el-form-item label="状态" prop="rquan_enable">
							<el-switch v-model="form.rquan_enable"
									   active-color="#13ce66"
									   :active-value="1" active-text="通过"
									   :inactive-value="-10" inactive-text="不通过">
							</el-switch>
						</el-form-item>
					</el-tab-pane>
					<!---->
					<!---->
					<el-tab-pane v-if="false" label="模板" name="2">
						<el-form-item label="应用模板" prop="reply_app_file" ref="reply_app_file">
							<el-col :span="6">
								<el-input v-model="form.reply_app_file" placeholder="默认：t_001"/>
							</el-col>
						</el-form-item>
					</el-tab-pane>
					<!---->
					<!---->
				</el-tabs>
			</el-form>
			<!---->
			<!---->
			<!-- 按钮部分 -->
			<div class="save_wrap">
				<el-button @click="g_page.funcBack" size="mini">返回</el-button>
				<el-button type="success" @click="g_page.funcSave" size="mini">保存</el-button>
				<el-checkbox v-if="page_info.is_admin_edit" style="margin-left: 10px;" label="保存后停留" v-model="checked"/>
			</div>
			<!---->
			<!---->
			<!---->
		</el-main>
	</el-container>
</template>

<script>
	import FileList from '@/components/UploadFile/UploadFileList'

	export default {
		components: {
			FileList
		},
		data() {
			let page_data = {
				file_accept: '.mp4'
			}
			//
			page_data = this.g_cc.funcGetInitData(page_data)
			//
			return page_data
		},
		mounted() {
			console.log('mounted')
			console.log(this.$route.query)

			this.g_page.funcSetVue(this)
			//
			this.g_page.funcSetApiUrlEdit('/xadmin/redbook/redbook__item__edit')
			this.g_page.funcSetApiUrlSave('/xadmin/redbook/redbook__item__edit/save')
			let page = this
			//验证
			this.form_rules = {
				__test: [{
					required: true,
					message: '请输入原密码',
					trigger: 'blur'
				}]
			}

			let data = this.$route.query
			this.g_page.funcEdit(data)
		},
		methods: {
			funcShowDialogAfter() {
				console.log('funcShowDialogAfter')
			},
			//保存之前
			funcSaveBefore(data) {
				console.log('funcSaveBefore', data)

				// data.abc_str_00 = this.g_page.funcImgArrToStr(data.abc_str_00_imgs)

				return data
			}
		}
	}
</script>
